package com.mercury.logs.config;

import com.mercury.logs.aop.aspect.MercuryLogAspect;
import com.mercury.logs.holder.SpringContextHolder;
import com.mercury.logs.listener.MercuryLogListener;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * 日志自动配置
 *
 * @author mercury
 */
@EnableAsync
@RequiredArgsConstructor
@ConditionalOnWebApplication
@Configuration
public class LogAutoConfiguration {

    @Bean
    public MercuryLogListener sysLogListener() {
        return new MercuryLogListener();
    }


    @Bean
    public MercuryLogAspect sysLogAspect() {
        return new MercuryLogAspect();
    }

    @Bean
    public SpringContextHolder springContextHolder() {
        return new SpringContextHolder();
    }

}

